package com.xiaoshuidi.cloud.module.contract.enums.contract;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 合同节点枚举类
 * 新签  | 续约 | 退租 | 换房
 *
 * @author 合房源码
 */
@Getter
@AllArgsConstructor
public enum ContractNodeEnum {

    NEW("2","new", "新签"),
    RENEWAL("4","renewal", "续约"),
    RENTING_OUT("3","renting_out", "退租"),
    EXCHANGE("5","exchange", "换房"),
    ;
    //编码
    private final String categoryType;
    //编码
    private final String code;
    //信息
    private final String msg;

    private static final Map<String, ContractNodeEnum> enumMap = new HashMap<>();

    static {
        ContractNodeEnum[] values = ContractNodeEnum.values();
        for (ContractNodeEnum value : values) {
            enumMap.put(value.getCode(), value);
        }
    }

    public static ContractNodeEnum getEnum(String num) {
        return enumMap.get(num);
    }

    public static String getBillTypeEnumByCode(String code) {
        ContractNodeEnum[] contractNodeEnums = values();
        for (ContractNodeEnum contractNodeEnum : contractNodeEnums) {
            if (contractNodeEnum.code.equals(code)) {
                return contractNodeEnum.code;
            }
        }
        return null;
    }

}
